#ifndef __YujcListener
#define __YujcListener

#include "gloox/client.h"
#include "gloox/connectionlistener.h"
#include "gloox/connectiontcpclient.h"
#include "gloox/rostermanager.h"
#include "gloox/mucroom.h"
#include <string>
#include <vector>

using namespace gloox;
using namespace std;

typedef void (*ThreadHandler)(void *);
typedef void (*PrintMessageToChat)(string message);
typedef void (*AddUserToList)(string jid, string username);

class YujcListener : public  ConnectionListener, public RosterListener
{
private:
	Client * j;
	vector<string> users;
public:
	MUCRoom * chat_room;

public:
	YujcListener(string name, string pass, PrintMessageToChat printMsg, AddUserToList addUsr);
	~YujcListener(void);
	void connect(ThreadHandler thread);
	virtual void handleRoster( const Roster& roster );
	std::string getUserJIDByIndex(int index);
private:
	void onConnect();
	void onDisconnect( ConnectionError e );

	AddUserToList addUserToComboBox;
	PrintMessageToChat putStringToChatWindow;

virtual void handleItemSubscribed( const JID& jid ){}
virtual void handleItemAdded( const JID& jid ){}
virtual void handleItemUnsubscribed( const JID& jid ){}
virtual void handleItemRemoved( const JID& jid ){}
virtual void handleItemUpdated( const JID& jid ){}
virtual void handleRosterError( const IQ& ){}
virtual void handleRosterPresence( const RosterItem& item, const string& resource,
	Presence::PresenceType presence, const string& ){}
virtual void handleSelfPresence( const RosterItem& item, const string& resource,
	Presence::PresenceType presence, const string& ){}

virtual bool handleSubscriptionRequest( const JID& jid, const std::string& )
{
  return true;
}
virtual bool handleUnsubscriptionRequest( const JID& jid, const std::string& )
{
  return true;
}
virtual void handleNonrosterPresence( const Presence& presence ){}

bool onTLSConnect( const CertInfo& )
{
	return true;
}	

};
#endif 
